import React from 'react'
import {Form, Input, Button,message,DatePicker } from 'antd'
import moment from "moment";
export default function table_Search(props:any) {
    const { RangePicker } = DatePicker;
    const rangeConfig = {
        rules: [{ type: 'array' as const, required: true, message: 'Please select time!' }],
      };
    const onFinish = (values: any) => {
        let value = {
            ...values
            
        };
        if(value.activityName == undefined){
            value.activityName = ''
        }
        if(value['datepicker'] == undefined){
            value['datepicker'] = []
        } else {
            console.log(value)
            let arr = []
            for(let item in value.datepicker){
                console.log(value.datepicker[item])
                let time = moment(value.datepicker[item]).format('YYYY-MM-DD')
                arr.push(time)
            }
            console.log(arr)
            value['datepicker'] = arr
            // value['datepicker'] = value['datepicker'].format('YYYY-MM-DD')
        }
       
        props.searchItem(value)
    };
    const onFinishFailed = (errorInfo: any) => {
        message.error('请填写必填项')
    };
    const reset = () =>{
    }
  return (
    <div>
          <Form
            name="basic"
            layout="inline"
            labelCol={{ span: 8 }}
            wrapperCol={{ span: 16 }}
            onFinish={onFinish}
            onFinishFailed={onFinishFailed}
            autoComplete="off"
            >
            <Form.Item
                label="活动名称"
                name="activityName"
            >
                <Input />
            </Form.Item>

            <Form.Item 
               name="datepicker" label="创建时间"
                >
                <RangePicker/>
            </Form.Item>
            <Form.Item wrapperCol={{ offset: 0, span: 24 }}>
                <Button type="primary" htmlType="submit" style={{background:'#1a267b',color:'white',borderRadius:'15px'}}>
                    搜索
                </Button>
                <Button htmlType="reset" onClick={reset} style={{borderRadius:'15px'}}>
                    重置
                </Button>
            </Form.Item>
        </Form>
    </div>
  )
}
